package cn.com.mayue.guava.collections;

import com.google.common.collect.Sets;
import org.junit.Test;

import java.util.Set;

/**
 * Created by mayue on 2016/12/22.
 */
public class SetsTest {
    @Test
    public void testDifference() {
        //创建set集合
        Set<String> setOne = Sets.newHashSet("1", "2", "3");
        Set<String> setTwo = Sets.newHashSet("2", "3", "4");
        //获取setOne 中存在 setTwo中不存在的
        System.out.println(Sets.difference(setOne, setTwo));
        //获取setTwo 中存在 setOne中不存在的
        System.out.println(Sets.difference(setTwo,setOne));
        //获取setOne setTwo 差异的元素
        System.out.println(Sets.symmetricDifference(setTwo,setOne));
        //获取setOne setTwo 交集
        System.out.println(Sets.intersection(setOne,setTwo));
        //并集
        System.out.println(Sets.union(setOne,setTwo));

    }
}
